package com.hjm.project.agentInfo.beautifulRecord.controller;

import java.util.List;

import com.hjm.project.agentInfo.beautifulRecord.beautifulRecord.domain.BeautifulRecord;
import com.hjm.project.agentInfo.beautifulRecord.service.IBeautifulRecordService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.hjm.framework.aspectj.lang.annotation.Log;
import com.hjm.framework.aspectj.lang.enums.BusinessType;
import com.hjm.framework.web.controller.BaseController;
import com.hjm.framework.web.domain.AjaxResult;
import com.hjm.common.utils.poi.ExcelUtil;
import com.hjm.framework.web.page.TableDataInfo;

import javax.annotation.Resource;

/**
 * 靓号变更记录Controller
 * 
 * @author maker-platform
 * @date 2021-03-01
 */
@Controller
@RequestMapping("/beautifulRecord/beautifulRecord")
public class BeautifulRecordController extends BaseController
{
    private String prefix = "agentInfo/beautifulRecord";

    @Resource
    private IBeautifulRecordService beautifulRecordService;

    @RequiresPermissions("beautifulRecord:beautifulRecord:view")
    @GetMapping()
    public String beautifulRecord()
    {
        return prefix + "/record";
    }

    /**
     * 查询靓号变更记录列表
     */
    @RequiresPermissions("beautifulRecord:beautifulRecord:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(BeautifulRecord beautifulRecord)
    {
        startPage();
        List<BeautifulRecord> list = beautifulRecordService.selectBeautifulRecordList(beautifulRecord);
        return getDataTable(list);
    }

    /**
     * 导出靓号变更记录列表
     */
    @RequiresPermissions("beautifulRecord:beautifulRecord:export")
    @Log(title = "靓号变更记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(BeautifulRecord beautifulRecord)
    {
        List<BeautifulRecord> list = beautifulRecordService.selectBeautifulRecordList(beautifulRecord);
        ExcelUtil<BeautifulRecord> util = new ExcelUtil<BeautifulRecord>(BeautifulRecord.class);
        return util.exportExcel(list, "beautifulRecord");
    }

    /**
     * 新增靓号变更记录
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存靓号变更记录
     */
    @RequiresPermissions("beautifulRecord:beautifulRecord:add")
    @Log(title = "靓号变更记录", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(BeautifulRecord beautifulRecord)
    {
        return toAjax(beautifulRecordService.insertBeautifulRecord(beautifulRecord));
    }

    /**
     * 修改靓号变更记录
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Integer id, ModelMap mmap)
    {
        BeautifulRecord beautifulRecord = beautifulRecordService.selectBeautifulRecordById(id);
        mmap.put("beautifulRecord", beautifulRecord);
        return prefix + "/edit";
    }

    /**
     * 修改保存靓号变更记录
     */
    @RequiresPermissions("beautifulRecord:beautifulRecord:edit")
    @Log(title = "靓号变更记录", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(BeautifulRecord beautifulRecord)
    {
        return toAjax(beautifulRecordService.updateBeautifulRecord(beautifulRecord));
    }

    /**
     * 删除靓号变更记录
     */
    @RequiresPermissions("beautifulRecord:beautifulRecord:remove")
    @Log(title = "靓号变更记录", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(beautifulRecordService.deleteBeautifulRecordByIds(ids));
    }
}
